$(function(){

	$.each($("li.btn_black"), function(i, item){

		$(item).toggle(function(){
			$(this).attr("class", "btn_red");
		}, function(){
			$(this).attr("class", "btn_black");
		});
	
	
	});

	
	
	$(".shuaixuancaidan dd:nth-child(1)").bind("click", function(){
		
		$.each($(this).parent().parent().parent().parent().parent().parent().find("li"), function(i, item){
			
			$(this).attr("class", "btn_red");
		});
	});
	
	
	$(".shuaixuancaidan dd:nth-child(9)").bind("click", function(){
		
		$.each($("#mainm_ml2l .top li"), function(i, item){
			
			$(this).attr("class", "btn_black");
		});
	});
	
	$("#xuanhaosubmit").bind("click", function(){
			
			var select_num = '';
			var mark1 = 0;
			$.each($(".baiwei").parent().find(".btn_red"), function(i, item){
				select_num += $(this).text();
				mark1 = i;
			});
			
			select_num += ",";
			var mark2 = 0;
			$.each($(".shiwei").parent().find(".btn_red"), function(i, item){
				select_num += $(this).text();
				mark2 = i;
			});
			
			select_num += ",";
			var mark3 = 0;
			$.each($(".gewei").parent().find(".btn_red"), function(i, item){
				select_num += $(this).text();
				var mark3 = 0;
			});
			
			var zhushu = (mark1 + 1) * ((mark2 + 1)) * (mark3 + 1);
			var selectedVal = "<ul><li class='li1'>3、一星直选复式</li><li class='li2'>"+ select_num +"</li><li class='li3'>"+ zhushu +"注</li><li class='li4'>￥" + zhushu * parseFloat("2.00") + "</li><li  class='x'>×</li></ul>";
			
			$(selectedVal).appendTo("#mainm_ml2r");
			//$(".mutlp_input").val(parseInt($(".mutlp_input").val()) + zhushu);
			$("#danbeizongzhushu").text(parseInt($("#danbeizongzhushu").text()) + zhushu);
			$("#danbeizongjine").text(parseFloat($("#danbeizongjine").text()) + zhushu *  parseFloat("2.00"));
			
			var codesVal = $("#codes").val();
			if(codesVal != ''){
				
				$("codes").val(codesVal + "$" + select_num);
			}else{
				
				$("codes").val(codesVal + select_num);
			}
			
			$("#onemoney").val($("#danbeizongjine").text());
			$("#allmoney").val(parseFloat($("#onemoney").val()) * parseInt($(".mutlp_input").val()));
			$("#beishu").val($(".mutlp_input").val());
			$("#expect").val($("#nowdatenumers").val());
			
	});
	
	$("#cleartzx").bind("click", function(){
		
		$("#mainm_ml2r").html('');
	});
	
	
	//是否追号
	$("#zhuihao_enter").bind("click", function(){	
		$("#customize_mult").val("1");
		$("#MenuMutiply1").attr("checked",true);
		$("#mult_tools").hide();
		$("#investment").hide();
		$("#mainm_ml3").show();
		var bets=$("#betting_slip").val();
		var bes=bets.split("@");
		if((bes.length-1)==1){
			$("#MenuMutiply2").attr("disabled",false);
		}else{
			$("#MenuMutiply2").attr("disabled",true);
		}
		zhuihaoInti();
	     var w = 300;
	     var h = 300;
		 popupDiv('main_ml3', w, h);
		 
	});
	
	function popupDiv(div_id, w, h){
	    var div_obj = $("#" + div_id);
	    var windowWidth = $(document).width();
	    var windowHeight = $(document).height();
	    var popupHeight =div_obj.width();
	    var popupWidth = div_obj.height();
	    var lefts=($(window).width() - popupWidth)/2+$(document).scrollLeft();	
	    var tops=($(window).height() - popupHeight)/ 2+$(document).scrollTop();
	   
	    $("<div id='mask'></div>").css({
	    'z-index': 7,
	    'color':'#000000',
	    'background-color':'#000000',
	    'position':'absolute',
	    'top':0,
	    'left':0,
	    'width':windowWidth,
	    'height':windowHeight,
		opacity:'0.8'
	    }).appendTo("body");
	    div_obj.css({
	    'z-index': '200',
	    "position": "absolute",
	    'top': tops,
		'left':lefts
	    }).animate({
	        opacity: "show"
	    }, 100);
	    
	    alert($(div_obj).html());
	}
	
	$("#clbet").click(function(){
		hideDiv('main_ml3');
		$("#chase").val("0");
	});
	
	function hideDiv(div_id){
	    $("#mask").remove();
	    $("#" + div_id).animate({
	        opacity: "hide"
	    }, 100);
	}


});